# s="A man, a plan, a canal: Panama"
s="       "
def isValid(ch):
    if (ch>="0" and ch<="9") or (ch>="a" and ch<="z") or (ch>="A" and ch<="Z"):
        return True
    else:
        return False
def isPalindrome(s):
    if s=="":
        #空串的情况
        return True
    left,right=0,len(s)-1
    while left<=right:
        while left<=right and not isValid(s[left]):
            #不是数字或者字母
            left+=1
        while left<=right and not isValid(s[right]):
            #不是数字或者字母
            right-=1
        if left<=right and s[left].upper()==s[right].upper():
            print("匹配成功")
            left+=1
            right-=1
        elif left<=right and s[left].upper()!=s[right].upper():
            return False

    return True
print(isPalindrome(s))